import tkinter as tk

import windows.ColorConfig as cc
from windows.SubWindows.SubWindowWidget import SubWindowWidget


class SubWindow:
    def __init__(self, Win, openPage=None):
        """
        主窗口副栏
        @param Win: 显示所在的窗口WindowsMain类
        """
        self.openPage = False
        if openPage is not None:
            self.openPage = openPage


        self.window = Win
        self.Frame = tk.Frame(self.window.win, bg=cc.DACK_BAKCGROUND)

        self.SubWindowWidget = SubWindowWidget()
        self.SubWindowWidget.register(self.Frame)

        self.boxPack()
        self.Frame.place(relwidth=1, relx=0, y=120, relheight=1)

    def getFrameSize(self) -> tuple:
        win_h, win_w = self.window.win.winfo_height(), self.window.win.winfo_width()
        frame_h, frame_w = win_h - 120, win_w
        frame_h = frame_h if frame_h >= 0 else 0
        return (frame_h, frame_w)

    def boxPack(self):
        """
        控件容器
        @return:
        """
        print("请重写该方法 以便进行控件的放置")

    def hidden(self):
        self.Frame.place_forget()

    def show(self):
        self.Frame.place(relwidth=1, relx=0, y=120, relheight=1)

